package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TestIndex;
import com.ruoyi.system.service.ITestIndexService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 首页信息Controller
 * 
 * @author ruoyi
 * @date 2022-05-14
 */
@RestController
@RequestMapping("/system/index")
public class TestIndexController extends BaseController
{
    @Autowired
    private ITestIndexService testIndexService;

    /**
     * 查询首页信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> list = testIndexService.selectTestIndexList(testIndex);
        return getDataTable(list);
    }
    @GetMapping("/doneList")
    public TableDataInfo doneList(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> list = testIndexService.selectTestIndexDoneList(testIndex);
        return getDataTable(list);
    }


    @GetMapping("/listNew")
    public TableDataInfo listNew(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> listNew = testIndexService.selectTestIndexListNew(testIndex);
        return getDataTable(listNew);
    }
    @GetMapping("/listNewChu")
    public TableDataInfo listNewChu(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> listNewChu = testIndexService.selectTestIndexListNewChu(testIndex);
        return getDataTable(listNewChu);
    }

    @GetMapping("/list2")
    public TableDataInfo list2(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> list2 = testIndexService.selectTestIndexList2(testIndex);
        return getDataTable(list2);
    }
    @GetMapping("/list3")
    public TableDataInfo list3(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> list3 = testIndexService.selectTestIndexList3(testIndex);
        return getDataTable(list3);
    }


    @GetMapping("/listWeek")
    public TableDataInfo listWeek(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> listWeek = testIndexService.selectTestIndexListWeek(testIndex);
        return getDataTable(listWeek);
    }
    @GetMapping("/doneListWeek")
    public TableDataInfo doneListWeek(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> listWeek = testIndexService.selectTestIndexDoneListWeek(testIndex);
        return getDataTable(listWeek);
    }

    @GetMapping("/listLine1")
    public TableDataInfo listLine1(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> listLine1 = testIndexService.selectTestIndexListLine1(testIndex);
        return getDataTable(listLine1);
    }

    @GetMapping("/listLine2")
    public TableDataInfo listLine2(TestIndex testIndex)
    {
        startPage();
        List<TestIndex> listLine2 = testIndexService.selectTestIndexListLine2(testIndex);
        return getDataTable(listLine2);
    }
    /**
     * 导出首页信息列表
     */
    @Log(title = "首页信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TestIndex testIndex)
    {
        List<TestIndex> list = testIndexService.selectTestIndexList(testIndex);
        ExcelUtil<TestIndex> util = new ExcelUtil<TestIndex>(TestIndex.class);
        util.exportExcel(response, list, "首页信息数据");
    }

    /**
     * 获取首页信息详细信息
     */
    @GetMapping(value = "/{assessId}")
    public AjaxResult getInfo(@PathVariable("assessId") Long assessId)
    {
        return AjaxResult.success(testIndexService.selectTestIndexByAssessId(assessId));
    }

    /**
     * 新增首页信息
     */
    @Log(title = "首页信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TestIndex testIndex)
    {
        return toAjax(testIndexService.insertTestIndex(testIndex));
    }

    /**
     * 修改首页信息
     */
    @Log(title = "首页信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TestIndex testIndex)
    {
        return toAjax(testIndexService.updateTestIndex(testIndex));
    }

    /**
     * 删除首页信息
     */
    @Log(title = "首页信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assessIds}")
    public AjaxResult remove(@PathVariable Long[] assessIds)
    {
        return toAjax(testIndexService.deleteTestIndexByAssessIds(assessIds));
    }
}
